//哈希表-两数之和
//暴力解法:
class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        for(int i = 0; i < nums.size(); i++)
            for(int j = 0; j < i; j++)
                if(nums[i] + nums[j] == target)
                    return {i, j};
        return {-1, -1};
    }
};

//哈希表: 空间换时间
class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        unordered_map<int, int> mp;
        for(int i = 0; i < nums.size(); i++)
        {
            if(mp.count(target - nums[i])) 
                return {mp[target - nums[i]], i};
            mp[nums[i]] = i;
        }
        return {-1, -1};
    }
};


//